/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import model.Responsible;


/**
 *
 * @author Adriano
 */
public class ResponsibleDAO implements DAO {

    private final DataSource dataSource;

    public ResponsibleDAO() {
        dataSource = new DataSource();
    }
    
    

     public void create(Object o) {
        try {
            String sql = "INSERT INTO responsible VALUES (null,?,?,?,?,?)";
            PreparedStatement ps = dataSource.getConnection().prepareStatement(sql);
            Responsible responsible = (Responsible) o;

            ps.setString(1, responsible.getTxtName());
            ps.setString(2, responsible.getTxtCpf());
            ps.setString(3,responsible.getTxtRg());
            ps.setString(4,responsible.getTxtQualification());
            ps.setString(5,responsible.getLstStatusR());
                
           
            int res = ps.executeUpdate();
            if (res == 0) {
                System.err.println("RESPONSIBLE.CREATE - Nenhum responsavel criado !");
            }
        } catch (SQLException e) {
            System.err.println("RESPONSIBLE.CREATE  - " + e.getMessage());
        }
    }


    public void delete(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); 
    }

    public void update(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); 
    }

    public Object read(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); 
    }
    
    public void closeDAO() {
        dataSource.closeConnection();
    }

}
